package deptServer

import (
	"context"
	v1 "devops-super/api/clusters/v1"
	"devops-super/internal/model/entity"
	"devops-super/internal/service"
	"github.com/gogf/gf/v2/os/gtime"
)

func (*ControllerV1) GetPageLst(ctx context.Context, req *v1.DeptServerPageLstReq) (res *v1.DeptServerPageLstRes, err error) {
	res = &v1.DeptServerPageLstRes{}
	res.PageLstRes, err = service.DeptServer().GetPageLst(ctx, req)
	return
}

func (*ControllerV1) Add(ctx context.Context, req *v1.DeptServerAddReq) (res *v1.DeptServerAddRes, err error) {
	record := &entity.AppDeptToServerRecord{
		DeptId:    req.DeptId,
		ServerKey: req.ServerKey,
		Type:      req.Type,
		Remark:    req.Remark,
		CreatedAt: gtime.Now(),
	}
	err = service.DeptServer().Add(ctx, record)
	return
}

func (*ControllerV1) Del(ctx context.Context, req *v1.DeptServerDelReq) (res *v1.DeptServerDelRes, err error) {
	err = service.DeptServer().Del(ctx, req)
	return
}
